<template>
	<div><b>请您编辑邮件~</b></div><br />
  <el-form :model="form" label-width="120px">
    <el-form-item label="邮件标题">
      <el-input v-model="email.title" />
    </el-form-item>
    <el-form-item label="收件人">
      <el-select v-model="email.receiverAddress" placeholder="请选择收件人">
        <el-option label="小明" value="小明@qq.com" />
        <el-option label="小芳" value="小芳@qq.com" />
        <el-option label="小奇" value="小奇@qq.com" />
        <el-option label="小熊" value="小熊@qq.com" />
        <el-option label="小能" value="小能@qq.com" />
       </el-select>
    </el-form-item>
    <el-form-item label="发送时间">
      <el-col :span="11">
        <el-date-picker
          v-model="email.sendTime"
          type="date"
          placeholder="Pick a date"
          style="width: 100%"
        />
      </el-col>
      <el-col :span="2" class="text-center">
        <span class="text-gray-500">-</span>
      </el-col>
      <el-col :span="11">
        <el-time-picker
          v-model="email.sendTime"
          placeholder="Pick a time"
          style="width: 100%"
        />
      </el-col>
    </el-form-item>
    <el-form-item label="附件类型">
      <el-checkbox-group v-model="email.extra">
        <el-checkbox label=".jpg图片" name="图片" />
        <el-checkbox label=".pdf文档" name="pdf" />
        <el-checkbox label=".zip压缩包" name="压缩包" />
        <el-checkbox label="其他" name="其他" />
      </el-checkbox-group>
    </el-form-item>
    <el-form-item label="邮件正文">
      <el-input v-model="email.text" type="textarea" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">发送</el-button>
      <el-button>暂存</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  import qs from 'qs'
  export default {
    name: "SendMail",
    data(){
		return{
			form:
			{
			  name: '',
			  region: '',
			  date1: '',
			  date2: '',
			  delivery: false,
			  type: [],
			  resource: '',
			  desc: '',
			},
			email:{
				attachment:''
			}
			
		}
    },methods:{
    	
	onSubmit(){
		var time2=this.email.sendTime
		var time1=time2.toString().substr(4,24)
		
		this.email.sendTime=time1
		for(let temp of this.email.extra)
		{
			this.email.attachment+=temp
		}
		this.email.extra=""
		let that=this
		let str=qs.stringify(that.email)
		this.$axios.get("http://localhost:8080/email_box/add?"+str).then(function(res){
			console.log(that.email)
		})
	}
    }
  }
</script>

<style scoped>

</style>